package com.kaka.bus.engine.home.info.question;

import com.kaka.bus.bean.HttpWrapper;
import com.kaka.bus.bean.QuestionBean;
import com.kaka.bus.di.DataManager;
import com.kaka.bus.manager.Result;
import com.kaka.bus.manager.T;
import com.kaka.bus.mvp.RxPresenter;

import java.util.List;

import javax.inject.Inject;

/**
 * Created by zhangqi on 2016/11/7.
 */

public class QuestionPresenter extends RxPresenter<QuestionContract.View> implements QuestionContract.Presenter {

    @Inject
    public QuestionPresenter(DataManager dataManager) {

        super(dataManager);
    }
    @Override
    public void initData(String userId, String token) {
        request(userId,token,0,0,false);
    }

    private void request(String userId, String token, int page, int pageSize, boolean isLoadMore){
        addSubscribe(mDataManager.getApi()
                .getQuestion(userId,token)
                .compose(T.D())
                .subscribeWith(new Result<HttpWrapper<List<QuestionBean>>>() {
                    @Override
                    protected void onSuccess(HttpWrapper<List<QuestionBean>> data) {
                        if(isLoadMore){

                        }else{
                            mView.onResultStart(data);
                        }
                    }

                    @Override
                    protected void onFaild() {
                        mView.onError();
                    }
                }));
    }


}
